#include "main.h"

void main()
{
    unsigned char Key_Num=0;
    unsigned int num=0;
    unsigned char Data=0;
    LCD_Init();
    // AT24C02_Write(2,70);
    // Delay(5);
    // AT24C02_Write(0,90);
    // Delay(5);
    // AT24C02_Write(3,71);
    // Delay(5);
    while(1)
    {
        LCD_ShowNum(1,1,num,5);
        Key_Num=key();
        if(Key_Num==1)
        {
            num++;
        LCD_ShowNum(1,1,num,5);
        }
        if(Key_Num==2)
        {
            num--;
        LCD_ShowNum(1,1,num,5);
        }
        if(Key_Num==3)
        {
            AT24C02_Write(0,num%256);
            Delay(5);
            AT24C02_Write(1,num/256);
            Delay(5);
            LCD_ShowString(2,1,"Write OK");
            Delay(1000);
            LCD_ShowString(2,1,"         ");
        }
        if(Key_Num==4)
        {
            num=AT24C02_Read(1);
            Delay(5);
            num=num*256+AT24C02_Read(0);
            Delay(5);
            LCD_ShowNum(1,1,num,5);
            LCD_ShowString(2,1,"Read OK");
            Delay(1000);
            LCD_ShowString(2,1,"         ");

        }



    }
}